using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._SpatialStatisticsTools._MappingClusters
{
    /// <summary>
    /// <para>Density-based Clustering</para>
    /// <para>Finds clusters of point features within surrounding noise based on their spatial distribution. Time can also be incorporated to find space-time clusters.</para>
    /// <para>根据周围噪声的空间分布查找点要素聚类。时间也可以被合并来寻找时空星团。</para>
    /// </summary>    
    [DisplayName("Density-based Clustering")]
    public class DensityBasedClustering : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public DensityBasedClustering()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_features">
        /// <para>Input Point Features</para>
        /// <para>The point features for which density-based clustering will be performed.</para>
        /// <para>将对其执行基于密度的聚类的点要素。</para>
        /// </param>
        /// <param name="_output_features">
        /// <para>Output Features</para>
        /// <para>The output feature class that will receive the cluster results.</para>
        /// <para>将接收聚类结果的输出要素类。</para>
        /// </param>
        /// <param name="_cluster_method">
        /// <para>Clustering Method</para>
        /// <para><xdoc>
        ///   <para>Specifies the method that will be used to define clusters.</para>
        ///   <bulletList>
        ///     <bullet_item>Defined distance (DBSCAN)— A specified distance will be used to separate dense clusters from sparser noise. DBSCAN is the fastest of the clustering methods but is only appropriate if there is a very clear distance to use that works well to define all clusters that may be present. This results in clusters that have similar densities.</bullet_item><para/>
        ///     <bullet_item>Self-adjusting (HDBSCAN)— Varying distances will be used to separate clusters of varying densities from sparser noise. HDBSCAN is the most data-driven of the clustering methods and requires the least user input.</bullet_item><para/>
        ///     <bullet_item>Multi-scale (OPTICS)—The distance between neighbors and a reachability plot will be used to separate clusters of varying densities from noise. OPTICS offers the most flexibility in fine-tuning the clusters that are detected, though it is computationally intensive, particularly with a large search distance.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定将用于定义群集的方法。</para>
        ///   <bulletList>
        ///     <bullet_item>定义距离 （DBSCAN）— 指定的距离将用于将密集簇与稀疏噪声分开。DBSCAN 是最快的聚类方法，但仅当有一个非常清晰的距离可供使用时才适用，该距离可以很好地定义可能存在的所有聚类。这会导致具有相似密度的聚类。</bullet_item><para/>
        ///     <bullet_item>自调整 （HDBSCAN）— 不同的距离将用于将不同密度的簇与稀疏噪声分开。HDBSCAN是聚类方法中数据驱动的方法，需要的用户输入最少。</bullet_item><para/>
        ///     <bullet_item>多尺度 （OPTICS） - 邻居之间的距离和可达性图将用于将不同密度的聚类与噪声分开。OPTICS 在微调检测到的集群方面提供了最大的灵活性，尽管它是计算密集型的，尤其是在搜索距离较大的情况下。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// </param>
        /// <param name="_min_features_cluster">
        /// <para>Minimum Features per Cluster</para>
        /// <para>The minimum number of points that will be considered a cluster. Any cluster with fewer points than the number provided will be considered noise.</para>
        /// <para>将被视为聚类的最小点数。任何点数少于所提供数的聚类都将被视为噪声。</para>
        /// </param>
        public DensityBasedClustering(object _in_features, object _output_features, _cluster_method_value? _cluster_method, long? _min_features_cluster)
        {
            this._in_features = _in_features;
            this._output_features = _output_features;
            this._cluster_method = _cluster_method;
            this._min_features_cluster = _min_features_cluster;
        }
        public override string ToolboxName => "Spatial Statistics Tools";

        public override string ToolName => "Density-based Clustering";

        public override string CallName => "stats.DensityBasedClustering";

        public override List<string> AcceptEnvironments => ["outputCoordinateSystem", "outputZFlag", "parallelProcessingFactor"];

        public override object[] ParameterInfo => [_in_features, _output_features, _cluster_method.GetGPValue(), _min_features_cluster, _search_distance, _cluster_sensitivity, _time_field, _search_time_interval];

        /// <summary>
        /// <para>Input Point Features</para>
        /// <para>The point features for which density-based clustering will be performed.</para>
        /// <para>将对其执行基于密度的聚类的点要素。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Point Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_features { get; set; }


        /// <summary>
        /// <para>Output Features</para>
        /// <para>The output feature class that will receive the cluster results.</para>
        /// <para>将接收聚类结果的输出要素类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _output_features { get; set; }


        /// <summary>
        /// <para>Clustering Method</para>
        /// <para><xdoc>
        ///   <para>Specifies the method that will be used to define clusters.</para>
        ///   <bulletList>
        ///     <bullet_item>Defined distance (DBSCAN)— A specified distance will be used to separate dense clusters from sparser noise. DBSCAN is the fastest of the clustering methods but is only appropriate if there is a very clear distance to use that works well to define all clusters that may be present. This results in clusters that have similar densities.</bullet_item><para/>
        ///     <bullet_item>Self-adjusting (HDBSCAN)— Varying distances will be used to separate clusters of varying densities from sparser noise. HDBSCAN is the most data-driven of the clustering methods and requires the least user input.</bullet_item><para/>
        ///     <bullet_item>Multi-scale (OPTICS)—The distance between neighbors and a reachability plot will be used to separate clusters of varying densities from noise. OPTICS offers the most flexibility in fine-tuning the clusters that are detected, though it is computationally intensive, particularly with a large search distance.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定将用于定义群集的方法。</para>
        ///   <bulletList>
        ///     <bullet_item>定义距离 （DBSCAN）— 指定的距离将用于将密集簇与稀疏噪声分开。DBSCAN 是最快的聚类方法，但仅当有一个非常清晰的距离可供使用时才适用，该距离可以很好地定义可能存在的所有聚类。这会导致具有相似密度的聚类。</bullet_item><para/>
        ///     <bullet_item>自调整 （HDBSCAN）— 不同的距离将用于将不同密度的簇与稀疏噪声分开。HDBSCAN是聚类方法中数据驱动的方法，需要的用户输入最少。</bullet_item><para/>
        ///     <bullet_item>多尺度 （OPTICS） - 邻居之间的距离和可达性图将用于将不同密度的聚类与噪声分开。OPTICS 在微调检测到的集群方面提供了最大的灵活性，尽管它是计算密集型的，尤其是在搜索距离较大的情况下。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Clustering Method")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _cluster_method_value? _cluster_method { get; set; }

        public enum _cluster_method_value
        {
            /// <summary>
            /// <para>Defined distance (DBSCAN)</para>
            /// <para>Defined distance (DBSCAN)— A specified distance will be used to separate dense clusters from sparser noise. DBSCAN is the fastest of the clustering methods but is only appropriate if there is a very clear distance to use that works well to define all clusters that may be present. This results in clusters that have similar densities.</para>
            /// <para>定义距离 （DBSCAN）— 指定的距离将用于将密集簇与稀疏噪声分开。DBSCAN 是最快的聚类方法，但仅当有一个非常清晰的距离可供使用时才适用，该距离可以很好地定义可能存在的所有聚类。这会导致具有相似密度的聚类。</para>
            /// </summary>
            [Description("Defined distance (DBSCAN)")]
            [GPEnumValue("DBSCAN")]
            _DBSCAN,

            /// <summary>
            /// <para>Self-adjusting (HDBSCAN)</para>
            /// <para>Self-adjusting (HDBSCAN)— Varying distances will be used to separate clusters of varying densities from sparser noise. HDBSCAN is the most data-driven of the clustering methods and requires the least user input.</para>
            /// <para>自调整 （HDBSCAN）— 不同的距离将用于将不同密度的簇与稀疏噪声分开。HDBSCAN是聚类方法中数据驱动的方法，需要的用户输入最少。</para>
            /// </summary>
            [Description("Self-adjusting (HDBSCAN)")]
            [GPEnumValue("HDBSCAN")]
            _HDBSCAN,

            /// <summary>
            /// <para>Multi-scale (OPTICS)</para>
            /// <para>Multi-scale (OPTICS)—The distance between neighbors and a reachability plot will be used to separate clusters of varying densities from noise. OPTICS offers the most flexibility in fine-tuning the clusters that are detected, though it is computationally intensive, particularly with a large search distance.</para>
            /// <para>多尺度 （OPTICS） - 邻居之间的距离和可达性图将用于将不同密度的聚类与噪声分开。OPTICS 在微调检测到的集群方面提供了最大的灵活性，尽管它是计算密集型的，尤其是在搜索距离较大的情况下。</para>
            /// </summary>
            [Description("Multi-scale (OPTICS)")]
            [GPEnumValue("OPTICS")]
            _OPTICS,

        }

        /// <summary>
        /// <para>Minimum Features per Cluster</para>
        /// <para>The minimum number of points that will be considered a cluster. Any cluster with fewer points than the number provided will be considered noise.</para>
        /// <para>将被视为聚类的最小点数。任何点数少于所提供数的聚类都将被视为噪声。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Minimum Features per Cluster")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public long? _min_features_cluster { get; set; }


        /// <summary>
        /// <para>Search Distance</para>
        /// <para><xdoc>
        ///   <para>The maximum distance that will be considered.</para>
        ///   <para>For the Clustering Method parameter's Defined distance (DBSCAN) option, the Minimum Features per Cluster parameter value must be found within this distance for cluster membership. Individual clusters will be separated by at least this distance. If a point is located farther than this distance from the next closest point in the cluster, it will not be included in the cluster.</para>
        ///   <para>For the Clustering Method parameter's Multi-scale (OPTICS) option, this parameter is optional and is used as the maximum search distance when creating the reachability plot. For OPTICS, the reachability plot, combined with the Cluster Sensitivity parameter value, determines cluster membership. If no distance is specified, the tool will search all distances, which will increase processing time.</para>
        ///   <para>If left blank, the default distance used will be the highest core distance found in the dataset, excluding those core distances in the top 1 percent (the most extreme core distances). If the Time Field parameter value is provided, a search distance must be provided and does not include a default value.</para>
        ///   <para>The maximum distance that will be considered.</para>
        ///   <para>For the cluster_method parameter's DBSCAN option, the min_features_cluster parameter value must be found within this distance for cluster membership. Individual clusters will be separated by at least this distance. If a point is located farther than this distance from the next closest point in the cluster, it will not be included in the cluster.</para>
        ///   <para>For the cluster_method parameter's OPTICS option, this parameter is optional and is used as the maximum search distance when creating the reachability plot. For OPTICS, the reachability plot, combined with the cluster_sensitivity parameter value, determines cluster membership. If no distance is specified, the tool will search all distances, which will increase processing time.</para>
        ///   <para>If left blank, the default distance used will be the highest core distance found in the dataset, excluding those core distances in the top 1 percent (he most extreme core distances). If the time_field parameter value is provided, a search distance must be provided and does not include a default value.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>将考虑的最大距离。</para>
        ///   <para>对于聚类分析方法参数的定义距离 （DBSCAN） 选项，必须在此距离内找到每个聚类的最小要素参数值才能成为聚类成员。单个集群将至少相隔此距离。如果某个点与聚类中下一个最近的点之间的距离远于此距离，则该点将不包括在聚类中。</para>
        ///   <para>对于聚类方法参数的多尺度 （OPTICS） 选项，此参数是可选的，在创建可达性图时用作最大搜索距离。对于光学器件，可达性图与簇灵敏度参数值相结合，确定簇成员资格。如果未指定距离，该工具将搜索所有距离，这将增加处理时间。</para>
        ///   <para>如果留空，则使用的默认距离将是数据集中找到的最高核心距离，不包括前 1% 的核心距离（最极端的核心距离）。如果提供了时间字段参数值，则必须提供搜索距离，并且不包含默认值。</para>
        ///   <para>将考虑的最大距离。</para>
        ///   <para>对于 cluster_method 参数的 DBSCAN 选项，必须在此距离内找到 min_features_cluster 参数值才能成为集群成员。单个集群将至少相隔此距离。如果某个点与聚类中下一个最近的点之间的距离远于此距离，则该点将不包括在聚类中。</para>
        ///   <para>对于 cluster_method 参数的 OPTICS 选项，此参数是可选的，在创建可达性图时用作最大搜索距离。对于光学器件，可达性图与cluster_sensitivity参数值相结合，决定了集群成员资格。如果未指定距离，该工具将搜索所有距离，这将增加处理时间。</para>
        ///   <para>如果留空，则使用的默认距离将是数据集中找到的最高核心距离，不包括前 1% 的核心距离（最极端的核心距离）。如果提供了 time_field 参数值，则必须提供搜索距离，并且不包括默认值。</para>
        /// </xdoc></para>
        /// <para>单位： Feet | Meters | Kilometers | Miles </para>
        /// </summary>
        [DisplayName("Search Distance")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public string? _search_distance { get; set; } = null;


        /// <summary>
        /// <para>Cluster Sensitivity</para>
        /// <para>An integer between 0 and 100 that determines the compactness of clusters. A number close to 100 will result in a higher number of dense clusters. A number close to 0 will result in fewer, less compact clusters. If left blank, the tool will find a sensitivity value using the Kullback-Leibler divergence that finds the value in which adding more clusters does not add additional information.</para>
        /// <para>介于 0 和 100 之间的整数，用于确定聚类的紧凑性。接近 100 的数字将导致更多数量的密集集群。接近 0 的数字将导致更少、更不紧凑的集群。如果留空，该工具将使用 Kullback-Leibler 散度查找灵敏度值，该散度查找添加更多聚类不会添加其他信息的值。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Cluster Sensitivity")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long? _cluster_sensitivity { get; set; } = null;


        /// <summary>
        /// <para>Time Field</para>
        /// <para>The field containing the time stamp for each record in the dataset. This field must be of type Date. If provided, the tool will find clusters of points that are close to each other in space and time. The Search Time Interval parameter value must be provided to determine whether a point is close enough in time to a cluster to be included in the cluster.</para>
        /// <para>包含数据集中每条记录的时间戳的字段。此字段的类型必须为“日期”。如果提供，该工具将查找在空间和时间上彼此接近的点聚类。必须提供搜索时间间隔参数值，以确定点在时间上是否足够接近集群以包含在集群中。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Time Field")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _time_field { get; set; } = null;


        /// <summary>
        /// <para>Search Time Interval</para>
        /// <para><xdoc>
        ///   <para>The time interval that will be used to determine whether points form a space-time cluster. The search time interval spans before and after the time of each point, so, for example, an interval of 3 days around a point will include all points starting 3 days before and ending 3 days after the time of the point.</para>
        ///   <para>
        ///     <bulletList>
        ///       <bullet_item>For the Clustering Method parameter's Defined distance (DBSCAN) option, the Minimum Features per Cluster parameter value must be found within the search distance and the search time interval to be included in a cluster.</bullet_item><para/>
        ///       <bullet_item>For the Clustering Method parameter's Multi-scale (OPTICS) option, all points outside of the search time interval will be excluded when calculating core distances, neighbor-distances, and reachability distances.</bullet_item><para/>
        ///     </bulletList>
        ///   </para>
        ///   <para>The search time interval does not control the overall time span of the resulting space-time clusters. The time span of points within a cluster can be larger than the search time interval as long as each point has neighbors within the cluster that are within the search time interval.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>将用于确定点是否形成时空聚类的时间间隔。搜索时间间隔跨越每个点的时间之前和之后，因此，例如，围绕一个点的 3 天间隔将包括从该点时间之前 3 天开始到该点时间之后 3 天结束的所有点。</para>
        ///   <para>
        ///     <bulletList>
        ///       <bullet_item>对于聚类分析方法参数的已定义距离 （DBSCAN） 选项，必须在要包含在聚类中的搜索距离和搜索时间间隔内找到每个聚类的最小要素参数值。</bullet_item><para/>
        ///       <bullet_item>对于聚类方法参数的多尺度 （OPTICS） 选项，在计算核心距离、相邻距离和可达距离时，将排除搜索时间间隔之外的所有点。</bullet_item><para/>
        ///     </bulletList>
        ///   </para>
        ///   <para>搜索时间间隔不控制生成的时空聚类的总时间跨度。只要每个点在聚类中具有位于搜索时间间隔内的相邻点，聚类中点的时间跨度就可以大于搜索时间间隔。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Search Time Interval")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _search_time_interval { get; set; } = null;


        public DensityBasedClustering SetEnv(object outputCoordinateSystem = null, object outputZFlag = null, object parallelProcessingFactor = null)
        {
            base.SetEnv(outputCoordinateSystem: outputCoordinateSystem, outputZFlag: outputZFlag, parallelProcessingFactor: parallelProcessingFactor);
            return this;
        }

    }

}